package top.dingwen.io.treasure.es.exception;

import lombok.Getter;
import top.dingwen.io.treasure.base.exception.ExceptionCode;
import top.dingwen.io.treasure.base.util.str.StringPlusUtils;
import top.dingwen.io.treasure.es.constant.EsConstant;

/**
 * es异常码
 *
 * @author dingwen
 * @since 2024/11/7 16:05
 */
@Getter
public enum EsExceptionCode implements ExceptionCode {
    /**
     * ES操作异常
     */
    ES_OP_EX("ES_EX", "ES操作异常", EsConstant.L_P_S, StringPlusUtils.EMPTY),
    /**
     * 索引创建失败
     */
    ES_INDEX_CREATE("ES_INDEX_CREATE", "索引创建失败", EsConstant.L_P_S, StringPlusUtils.EMPTY);

    /**
     * 异常码
     */
    private final String exCode;

    /**
     * 消息
     */
    private String message;

    /**
     * 所属模块
     */
    private final String module;

    /**
     * 消息键
     */
    private final String key;


    /**
     * 通用异常码构造器
     *
     * @param exCode  异常码
     * @param message 消息
     * @param module  所属模块
     * @param key     消息键
     */
    EsExceptionCode(String exCode,
                    String message,
                    String module,
                    String key) {
        this.exCode = exCode;
        this.message = message;
        this.module = module;
        this.key = key;
    }

    @Override
    public void setMessage(String message) {
        this.message = message;
    }
}
